/*
1、题目：915. 分割数组：https://leetcode.cn/problems/partition-array-into-disjoint-intervals/
2、不难，容易犯错
*/
class Solution {
public:
    int partitionDisjoint(vector<int>& nums) {
        int lmax = nums[0], curmax = nums[0], pos = 0;
        for(int i = 1; i < nums.size()-1; i++){
            curmax = max(curmax,nums[i]);
            if(lmax > nums[i]){
                lmax = curmax;
                pos = i;
            }
        }
        return pos+1;
    }
};